import type { Users } from '@/types/user'

import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useUserStores = defineStore(
  'cp-users',
  () => {
    // 用户信息
    const users = ref<Users>({
      token: '',
      id: ''
    })

    const addUsr = (token: string) => {
      users.value.token = token
    }

    const getId = (id: any) => {
      users.value.id = id
    }
    const deleteUsr = () => {
      users.value.token = ''
      users.value.id = ''
    }
    return { users, addUsr, getId, deleteUsr }
  },
  {
    persist: true
  }
)
